using System;
using Microsoft.Practices.ObjectBuilder2;
using Microsoft.Practices.Unity;
using Common.Core;

namespace Common.Unity.Configuration
{
	class DependencyResolverParameterValue : InjectionParameterValue
	{
		readonly IDependencyResolverPolicy policy;
		readonly Type parameterType;

		public DependencyResolverParameterValue( IDependencyResolverPolicy policy, Type parameterType )
		{
			this.policy = policy;
			this.parameterType = parameterType;
		}

		public override bool MatchesType( Type t )
		{
			var result = parameterType.IsAssignableFrom( t );
			return result;
		}

		public override IDependencyResolverPolicy GetResolverPolicy( Type typeToBuild )
		{
			return policy;
		}

		public override string ParameterTypeName
		{
			get { return parameterType.AssemblyQualifiedName; }
		}
	}
}